'use strict';

var path = require('path');
var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var express = require('express');
var ROOT_PATH = path.resolve(__dirname);
var srcDir = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'assets');
var BUILD_PATH_JS = path.resolve(ROOT_PATH, 'assets/js');
var app = express();
var debug = app.get('env') === 'development';
var pak = require('./package.json');
console.log('process.env',process.env)
module.exports= {
  entry: {
    entry1: path.resolve(srcDir, 'app.jsx')
  },
  output: {
    path: BUILD_PATH,
	filename: debug ? 'js/[hash:8]/[name].js' : 'js/[chunkhash:8].[name].min.js',
	chunkFilename: debug ? 'js/chunk.js' : 'js/[chunkhash:8].chunk.min.js'
  },
  //enable dev source map
  devtool: 'eval-source-map',
  //enable dev server
  devServer: {
    historyApiFallback: true,
    hot: true,
    inline: true,
    progress: true
  },
  //babel重要的loader在这里
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel'
      },
      {
        test: /\.css?$/,
        loader: 'style!css'
      },
      {
        test: /\.png?$/,
        loader: 'url'
      }
    ]
  },
	resolve: {
		extensions: ['', '.js','.jsx', '.css', '.tpl', '.png', '.jpg']
	},
  plugins: [
    new HtmlwebpackPlugin({
      title: pak.description,
	  filename: 'index.html',
      inject: 'body',
      template: './src/tmpl/main.html'
    })
  ]
};